package cn.zwxky.android.staff.Jurisdiction.Furlough;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.zgscwjm.lsfbbasetemplate.Event.LsfbEvent;
import com.zgscwjm.lsfbbasetemplate.adapter.CommonRecycAdapter;
import com.zgscwjm.lsfbbasetemplate.adapter.ViewHolderRecyc;

import java.util.List;

import cn.zwxky.android.staff.R;
import cn.zwxky.android.staff.Utils.URLString;

/**
 * Created by Administrator on 2017/4/6 0006.
 */

public class ManageLeaveAdapter extends CommonRecycAdapter<ManageLeaveBean.ListBean> {
    private Context mcotext;
    public ManageLeaveAdapter(Context context, List<ManageLeaveBean.ListBean> list, int layoutId) {
        super(context, list, layoutId);
        mcotext=context;
    }

    @Override
    public void convert(ViewHolderRecyc holder, final ManageLeaveBean.ListBean model) {
        holder.setImg(R.id.item_leave_img_head, URLString.IMG_URL+model.getImg(),R.mipmap.img_my_details_head);
        holder.setText(R.id.item_leave_text_title,model.getName());
        holder.setText(R.id.item_leave_text_start_time,"开始时间："+model.getStart());
        holder.setText(R.id.item_leave_text_end_time,"结束时间："+model.getEnd());
        holder.setText(R.id.item_leave_text_way,"请假事由："+model.getContent());

        TextView textView=holder.getView(R.id.item_leave_text_status);

        //0审批中，1通过，2拒绝
        if (model.getStatus().equals("0")){
            holder.setText(R.id.item_leave_text_status,"待处理");
            textView.setTextColor(mcotext.getResources().getColor(R.color.label_yellow));
        }else if (model.getStatus().equals("1")){
            holder.setText(R.id.item_leave_text_status,"通过");
            textView.setTextColor(mcotext.getResources().getColor(R.color.label_green));
        }else if (model.getStatus().equals("2")){
            holder.setText(R.id.item_leave_text_status,"拒绝");
            textView.setTextColor(mcotext.getResources().getColor(R.color.label_red));
        }

        holder.setOnclick(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ManageLeaveClickEvent even = new ManageLeaveClickEvent();
                even.setData(model.getId());
                LsfbEvent.getInstantiation().post(even);
            }
        });
    }
}
